package com.lw.sbdemo2.web;

import com.lw.sbdemo2.common.utils.IdUtils;
import com.lw.sbdemo2.common.web.anno.Required;
import com.lw.sbdemo2.common.base.BaseController;
import com.lw.sbdemo2.common.vo.PageInfo;
import com.lw.sbdemo2.entity.TkOpinionCallback;
import com.lw.sbdemo2.service.TkOpinionCallbackService;
import com.lw.sbdemo2.common.web.anno.ResultController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * <p>标题: 用户意见反馈表服务 - 请求控制层</p>
 * <p>描述: </p>
 * <p>版权: Copyright (c) 2019</p>
 * <p>公司: 山人行工作室</p>
 *
 * @version: 1.0
 * @author: LinWang
 * @date 2019-4-14
 */
@ResultController
@Api(description = "TkOpinionCallbackController", tags = {"用户意见反馈表服务"})
@RequestMapping(value = "/tkOpinionCallback")
public class TkOpinionCallbackController extends BaseController {

    /**
     * 用户意见反馈表服务
     */
    @Autowired
    private TkOpinionCallbackService tkOpinionCallbackService;
	
	@ApiOperation(value = "获取用户意见反馈表列表")
    @GetMapping("")
    public List<TkOpinionCallback> findList(TkOpinionCallback tkOpinionCallback) {
        return tkOpinionCallbackService.findList(tkOpinionCallback);
    }

    @ApiOperation(value = "获取用户意见反馈表列表（分页）", response = PageInfo.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "query", value = "关键词", dataType = "string"),
            @ApiImplicitParam(name = "pageNum", value = "当前页码", required = true, dataType = "int"),
    })
    @GetMapping(value = "/page")
    public PageInfo<TkOpinionCallback> page(String query, @Required("pageNum") PageInfo pageInfo, TkOpinionCallback tkOpinionCallback) {
        return tkOpinionCallbackService.findListPage(query, pageInfo, tkOpinionCallback);
    }

    @ApiOperation(value = "获取用户意见反馈表详细信息", notes = "根据url的id来获取用户意见反馈表详细信息")
    @ApiImplicitParam(name = "id", value = "用户意见反馈表ID", required = true, dataType = "String")
    @GetMapping("/{id}")
    public TkOpinionCallback get(@PathVariable String id) {
        return tkOpinionCallbackService.getById(id);
    }

    @ApiOperation(value = "创建用户意见反馈表")
    @PostMapping("/insert")
    public void insert(TkOpinionCallback tkOpinionCallback) {
        tkOpinionCallback.setOpinionId(IdUtils.uuid());
        tkOpinionCallback.setOpinionTime(new Date());
        tkOpinionCallbackService.insert(tkOpinionCallback);
    }

    @ApiOperation(value = "更新用户意见反馈表详细信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "用户意见反馈表ID", required = true, paramType = "query", dataType = "String")
    })
    @PostMapping("/update")
    public void update(TkOpinionCallback tkOpinionCallback) {
        tkOpinionCallbackService.update(tkOpinionCallback);
    }

    @ApiOperation(value = "删除用户意见反馈表", notes = "删除用户意见反馈表")
    @ApiImplicitParam(name = "id", value = "用户意见反馈表ID", required = true, paramType = "query", dataType = "String")
    @PostMapping("/delete")
    public void deleteTkOpinionCallback(TkOpinionCallback tkOpinionCallback) {
        tkOpinionCallbackService.delete(tkOpinionCallback);
    }
    
}